using System.Collections;
using System.Collections.Generic;
using Commons;
using Datas;
using Mgrs;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

public class EventCardcontrol : ComMonoBehaviour
{
    // Start is called before the first frame update
    /**事件卡预制体*/
    public GameObject eventCardPre;
    public GameObject medicineCarPre;

    public GameObject DialogPre;

    public GameObject shopPre;
    
    private PatientDialog p;
    

    private  GameObject _c1,_c2,_c3,_m1,_m2,_m3;
    void Start()
    {
        ShowEventCard();
        
        
        // 注册点击事件卡消息
        RegisterMsg(MsgData.ClickEventCard, GetEventcardMessage);
        
    }

    protected override void OnBeforeDestroy()
    {
    }

    // Update is called once per frame
    void Update()
    {

    }

   public void ShowEventCard()
    {
        _c1=Instantiate(eventCardPre,transform);
        _c2=Instantiate(eventCardPre,transform);
        _c3=Instantiate(eventCardPre,transform);
    }

   public void ShowMedicineCard()
   {
       _m1=Instantiate(medicineCarPre,transform);
       _m2=Instantiate(medicineCarPre,transform);
       _m3=Instantiate(medicineCarPre,transform);
   }
   

   public  void Destroycard()
    {
        GameObject.Destroy(_c1);
        GameObject.Destroy(_c2);
        GameObject.Destroy(_c3);
    }

    public void DestroyMedicineCard()
    {
        GameObject.Destroy(_m1);
        GameObject.Destroy(_m2);
        GameObject.Destroy(_m3);
    }
    
    //接收是事件卡的消息
    void GetEventcardMessage(object getCarId)
    {
        Destroycard();
        
        switch (getCarId)
        {
            case 0:
                Debug.Log("草药事件");
                ShowMedicineCard();
                break;
            case 1:
                Debug.Log("病人事件");
                PatientEvent();
                break;
            case 2:
                Debug.Log("路口事件");
                Nextevent();
                break;
            case 3:
                Debug.Log("商人事件");
                merchant();
                break;
        }
        
    }

    void GetmedicineCarMessage()
    {
        DestroyMedicineCard();
         ShowEventCard();
    }


    /**病人事件*/
    void PatientEvent()
    {
        var  Dialog= Instantiate(DialogPre, transform);
        Dialog.GetComponent<Dialog>().DialogueEvent(DialogType.PatientEvent);
    }

    /**下个路口事件*/
    void Nextevent()
    {
        var Dialog= Instantiate(DialogPre,transform);
        Dialog.GetComponent<Dialog>().DialogueEvent(DialogType.NextEvent);
    }

    void merchant()
    {
        var Dialog= Instantiate(DialogPre,transform);
        Dialog.GetComponent<Dialog>().DialogueEvent(DialogType.Merchant);
    }


    public void ShowShop()
    {
        Instantiate(shopPre, transform);
    }
   


  

}
